﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ra2map_plus.data
{
    class Project
    {
        public string location { set; get; }

        /// <summary>
        /// outputDirs 使用绝对路径
        /// </summary>
        public List<string> outputDirs { set; get; }

        /// <summary>
        /// rootIniFile 使用相对于项目 location 的相对路径
        /// </summary>
        public string rootIniFile { set; get; }

        /// <summary>
        /// includeIniDirs 使用相对于项目 location 的相对路径
        /// </summary>
        public List<string> includeIniDirs { set; get; }

        /// <summary>
        /// outputFileName 使用相对于项目 location 的相对路径
        /// </summary>
        public string outputFileName { get; set; }

        public Project fieldDesc { set; get; }

        public Project mergeNonNullProperties(Project otherProject)
        {
            if (otherProject.outputDirs != null && otherProject.outputDirs.Count > 0)
            {
                this.outputDirs = otherProject.outputDirs;
            }
            if (!string.IsNullOrWhiteSpace(otherProject.rootIniFile))
            {
                this.rootIniFile = otherProject.rootIniFile;
            }
            if (otherProject.includeIniDirs != null && otherProject.includeIniDirs.Count > 0)
            {
                this.includeIniDirs = otherProject.includeIniDirs;
            }
            if (!string.IsNullOrWhiteSpace(otherProject.outputFileName))
            {
                this.outputFileName = otherProject.outputFileName;
            }

            if (this.fieldDesc != null && otherProject.fieldDesc != null)
            {
                this.fieldDesc.mergeNonNullProperties(otherProject.fieldDesc);
            }
            return this;
        }

        private Project() { }

        public Project(string location, string rootIniFile, string outputFileName, List<string> includeIniDirs, List<string> outputDirs)
        {
            this.location = location;
            this.outputDirs = outputDirs;
            this.includeIniDirs = includeIniDirs;
            this.rootIniFile = rootIniFile;
            this.outputFileName = outputFileName;
        }

        public Project(string location, string rootIniFile, string outputFileName) : this(location, rootIniFile, outputFileName,new List<string>(), new List<string>()) { }
    }
}
